/**
 * 
 */
package org.universalmvc.config;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * @author vj
 *
 */
public class FileConfigurationSource implements ConfigurationSource {
	private Log log = LogFactory.getLog(FileConfigurationSource.class);
	
	private String filePath;
	private FileInputStream fis;
	
	/**
	 * @return the filePath
	 */
	public String getFilePath() {
		return filePath;
	}

	/**
	 * @param filePath the filePath to set
	 */
	public void setFilePath(String filePath) {
		this.filePath = filePath;
	}

	public FileConfigurationSource(String filePath) {
		this.filePath = filePath;
		try {
			this.fis = new FileInputStream(filePath);
		} catch(FileNotFoundException fnfe) {
			log.error(String.format("Log file: %s not found", filePath));
		}
	}

	@Override
	public InputStream getInputStream() {
		return fis;
	}
}
